package com.example.joke.custom.indicator;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.annotation.GlideType;
import com.example.joke.R;
import com.example.joke.custom.indicator.eg.HolderCreator;

/**
 * @Description
 * @Author zhidachang
 * @Time 2020-04-27 17:46
 */
public class BannerHolderCreator implements HolderCreator {

  @Override
  public View createView(Context context, int index, Object o) {
    View view = LayoutInflater.from(context).inflate(R.layout.banner_holder, null);
    ImageView imageView = view.findViewById(R.id.iv);
    if (!(o instanceof String)) {
      return imageView;
    }
    String s = (String) o;
    if (null == s || TextUtils.isEmpty(s)) {
      return imageView;
    }
    Glide.with(context)
        .load(s)
        .into(imageView);

    return view;
  }
}
